package lumis.portal.dao.hibernate;

import java.io.Serializable;

import lumis.util.PortalUtil;

import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;

/**
 * Identifier generator for hibernate that uses
 * {@link PortalUtil#generateNewGuid()} to generate the identifier.
 * 
 * @version $Revision: 6251 $ $Date: 2007-03-27 10:49:29 -0300 (Tue, 27 Mar 2007) $
 * @since 4.0.4
 */
public class GuidGenerator implements org.hibernate.id.IdentifierGenerator
{
	/**
	 * Calls {@link PortalUtil#generateNewGuid()} to generate the identifier.
	 * @param session
	 * @param object the entity or toplevel collection for which the id is being generated
	 * @return the identifier generated.
	 * @since 4.0.4
	 */
	public Serializable generate(SessionImplementor session, Object object) throws HibernateException
	{
		return PortalUtil.generateNewGuid();
	}
}
